package com.controller;


import com.model.Video;
import com.service.VideoService;
import com.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("api/v1/pub/video")
@RestController
public class VideoController {


    @Autowired
    private VideoService videoService;

    /**
     * 返回视频列表
     * @return
     */
    @RequestMapping("list")
    public JsonData listVideo(){
        List<Video> list=videoService.listVideo();
        return list==null?JsonData.buildError("获取视频失败"):JsonData.buildSuccess(list);
    }

    /**
     * 查询视频详情
     * @param videoId
     * @return
     */
    @GetMapping("find_detail_by_id")
    public JsonData findDetailById(@RequestParam(value = "video_id",required = true) int videoId){
        Video video=videoService.findDetailById(videoId);
        return video==null?JsonData.buildError("查找失败"):JsonData.buildSuccess(video);
    }
}
